<?php
namespace app\admin\controller;
use think\Controller;
use think\helper\Time;


class Update extends Controller{


    public function index(){
      ignore_user_abort (true);
      set_time_limit(0);
     
      $olds=db('OldMember')->where('aid=2')->select();
      $total=count($olds);
      // mylog($olds);
      $table=db('AdminUser');
      foreach ($olds as $key => $value) {
       $have=$table->where('mobile',$value['mobile'])->find();
       // $data['aid']=2;
       // $data['shopid']=$value['shopid'];
       // $data['userid']=$value['mobile'];
       // $data['name']=$value['name'];
       // $data['simple_name']=$value['simple_name'];
       // $data['nickname']=$value['nickname'];
       // $data['password']='123456';
       // $data['birthday']=$value['birthday'];
       // $data['calendar']=$value['calendar'];
       // $data['status']=$value['status'];
       // $data['mobile']=$value['mobile'];
       // $data['qq']=$value['qq'];
       // $data['email']=$value['email'];
       // $data['avatar']=$value['avatar'];
       // $data['marriage']=$value['marriage'];
       // $data['idcard']=$value['idcard'];
       // $data['bankcard']=$value['bankcard'];
       // $data['joinday']=$value['joinday'];
       // $data['marriage']=$value['marriage'];
       // $data['marriage']=$value['marriage'];
       // $data['marriage']=$value['marriage'];
       unset($value['id']);
       unset($value['motto']);
       unset($value['out_description']);
       unset($value['can_aid']);
       unset($value['Latitude']);
       unset($value['Longitude']);
       unset($value['Precision']);
       unset($value['rob']);
       unset($value['uid']);
       unset($value['openid']);
       unset($value['username']);
       unset($value['con_check']);
       unset($value['total_check']);
       unset($value['reg_ip']);
       unset($value['reg_time']);
       unset($value['last_login_role']);
       unset($value['show_role']);
       unset($value['signature']);
       unset($value['show_role']);
       if ($value['status']>1)$value['status']=1;
       $value['password']='4242e1a55a65777f164e00dba266af27';
       $value['role_id']=2;
       if ($have){
              //看看是否操作数据库
            
                $res= $table->where('mobile',$value['mobile'])->update($value);
                echo $key.'/'.$total.':'.$value['name'].'更新</br>';
             
               
            }else{
           
             
              $res=$table->insert($value);
              mymysql($table);
              echo $key.'/'.$total.':'.$value['name'].'插入</br>';
       }
       ob_flush(); 
       flush();  
          
      }
     
  
       
    }

   
}